<template>
  <div>
    <div style="display: flex;align-items: center;justify-content: center;">
      <el-card style="width: 80%;margin-top: 30px">
        <div style="margin-bottom: 10px;margin-left:5px;font-size: 20px;font-weight: bold;">评价</div>
        <div style="margin-bottom: 10px">
        </div>
        <el-table :data="commentData" stripe
                  :header-cell-style="{backgroundColor:'aliceblue',color:'#666'}">
          <el-table-column prop="id" label="评论id"></el-table-column>
          <el-table-column prop="username" label="用户名"></el-table-column>
          <el-table-column prop="content" label="内容"></el-table-column>
          <el-table-column prop="time" label="时间"></el-table-column>
        </el-table>
        <div style="margin: 10px 0">
          <el-pagination
              @current-change="handleCurrentChange"
              :current-page="pageNum"
              :page-sizes="[100, 200, 300, 400]"
              :page-size="pageSize"
              layout="total,  prev, pager, next"
              :total="total">
          </el-pagination>
        </div>
      </el-card>
    </div>

  </div>
</template>
<script>
export default {
  name: "comment",
  data() {
    return {
      user: JSON.parse(localStorage.getItem('user') || '{}'),
      pageNum: 1,
      pageSize: 5,
      total: 0,
      commentData: [],
    }
  },
  methods: {
    load() {
      this.$request.post('/comment_list/', {
        "business_id": this.user.id,
        "page_size": this.pageSize,
        "page_id": this.pageNum,
      }).then(res => {
        if (res.code === '200') {
          this.commentData = res.data.comment_list;
          this.total = res.data.item_amount;
        } else if (res.code === '501') {
        } else {
          this.$message.error(res.msg)
        }
      })
    },
    handleCurrentChange(pageNum) {
      this.load(pageNum)
    },
    reset() {
      this.load()
    },
  },
  created() {
    this.load()
  },
  mounted() {
  },
}
</script>
<style scoped>

</style>